Added world boundary check