refactored the basic files, there are some errors, fix them later.