add error handling from @BenV