refactor to allow clustering