Refactor complexity calculation to include variables and simplify

## Story

https://www.pivotaltracker.com/story/show/80044914

## Notes

Hoping this implementation is also clearer than the previous one