Refactor profile parsing