Slightly nicer version of this script that doesn't crash.