Added cluster and improved code structure