refactored with ability to switch off