move check_range to math/error_handling/matrix