fix some problems and add print functions