refactor js file for profile page