added validation of coordinates