refactored main activity