This version of code is NOT working. Saving it here so I can revert to earlier version and see what went wrong.