handle spawn ENOENT error & remove unnecessary function