use exec instead of system, adapt suggestions from mvidner