refactor and test structure