fix catchErr function