reusing variables to save memory
handling the case of nan ys
incremented artifact coordinates