fix permission condition on JS