Handle none object exceptions better