Fixes potential crash from invalid y value