first refactor and clean