Refactored permissions code to HEAD