Added tolerance to menu control and refactored