Refactored enter handling method.