Add validation for the values of x and y