better entrance and exit checking