error-handling added