cleanup & refactor