New functional way of error catching