further refactor & cleanup