move process exit code to a func