Refactored method of catching enter.