initial version is completed. make no warnings. not tested yet