added error throwing