fix error raising bug