modified HPSNR function

modified HPSNR function for error condition