Stable-ish version with basic errorchecking