fix error throwing order