slight enhancements + refactoring