refactor, add clustering