Fixed "isAllowed" function. It has to be implemented in a better way, though