Refactor the profile management