now takes x and y as passed parameters