added exception handling via littlewatson