more structure, add tests