This is my first working version. I need to clean this up.