Moved chmod command ahead of opts move, to remove the use of sudo