fix coordinate calculation