refactored the cluster engine