fixed permissions checking