refactored code,  added overridable settings