Spaghetti code that seems to work.
Less spaghetti and it (still) works.
Less spaghetti.
Made the model dynamic.