added error checking for 2d haar transform