Updated Code to Adam's cleaned/fixed code.
Updated Code to Adam's cleaned/fixed code.