Added error throwing code.