Fix Y coordinate calculation