add of permissions handling + code cleanup