fix a bug in final cooling function