Refactor and fix one TODO