Refactored profile code