more general cost functions