Added permissions checking