Is there a better way to go about this? Also a problem

The main problem is that you can’t totally automate this, because you need different code for each effect.

Having said that, it would be much neater, to put all the ‘from’/‘to’ values in arrays, which you could then use with a timeline