refactoring for more readable activity code