Got it working in one file

Now I need to separate out the logic part