That sounds right, assuming x and y are in a proper range,
and you don't have other bugs.