refactoring beacon triggering to a state type pattern