Fixed error check