Original version written in Processing