function to write cluster