Added some error proofing.