refactor
define trial utility function