[TASK] Code cleanup
[TASK] Refactoring and add intermediate variables