Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
I've turned the functions into variables using a dictionary, that way I could shrink a lot the result function. What do you think of it? The updated code is in the OP.