Refactor, added logger