changed 0 to -distance in x coordinate of clearRect