refactor and added unit tests