refactor and logger