ML with some while true issues fixed