refactored activity
refactoring and fixing bugs