Initial Code Dump from Original Attempt