Changed ERROR_VAL to -1