Dev/davide di carlo/permissions

Improve permissions checking