convert execvp error handling to switch statement