cleaned up the code. Now straightforward way of getting image coordinates