simplified handling of bad function passed as argument to the program. Removed dead code