adding boundry checks for input cordinates
Signed-off-by: root <root@sagar-vm.(none)>