Made some improvements
Added permission checks