Refactoring: move general functions from main activity to Utils