Error function can now be defined via passing a lambda