changed structure, added tests