modified code to check if a user has a role