refactor and make clean