move some commands to a subshell

they were executed in the wrong directory