refactoring
added test