created a wrapper for input handling with closures