refactoring & code cleanup