Fixed chmod to 0777 instead of 777