Added some more error-handling just to be on the safe side.