some refactoring after reviewing #10