Refactor profile.erl for clarify