add error handling for invalid file paths
refactor CallSingleCommand