code cleanup
refactoring for preferences use