fix permission handling