refactor and hotfix