-fixed a bug in an error check that caused an assertion to fail for no reason