create_cluster with modularised code