added CLI mode and user defined functions