Rewrite the update query, so it doesn't crap out anymore