Refactored render func logic into separate units