adding code from Todd