Fixed bugs when going back to activity