moved some utility functions from TopFit.lua to utilities.lua