Optimizing costs on the cloud