Changed nextDirection to take image parameter and return image.