higher order functions
added runtime errors and exceptions