Add cost functions
First implemention of min-by
Refactoring min-by to be used as a High Order Funtion