refactored structure; added JUnit test class.