huge refactoring done