Fixed bug in check_derivatives properly this time