Role determination moved to functions
Role determination moved to functions