Refactored code to move valid profile check from controller to model