refactoring complete. but compile slowly !