Added logic to prevent dead character movements