major changes & refactoring