minutocash-20 make a reusable function for error checking