Use chmod 775 in place of chmod 777