basic functions completed by hlzhang