Reusable way of checking permission