Throughout the codebase we have various duplicated code. Refactoring these into dedicated function increases readability and maintainability.