Add error checking for exec call