moved exec to after error check