modify functions

modify input/output stuff and other minor changes