structure changes. added unit tests