refactoring, writing is still not totally correct