Still trying to get this to work.

Unfortunately the code is getting messier and messier. So it goes.