Great, now use some functions. From the library or your own, and see this complexity become manageable.
That's what abstraction is about.