Refactoring + add test