refactoring & fixes