refactore code in startactivity