Correct functionality

The code has been moved into a single exec command to fix the
functionality.