refactored collision detection

added coordinates() function to simplify getting those values.