refactored and fixed bugs in cluster recipe