fixed permissions issue by piping to sudo tee -a
fixed more permissions bugs