refactor and clean