final code of user access control