moved cluster code into it's own class