Refactor: Using higher-order function to remove duplication (1)
Refactor: Using higher-order function to remove duplication (2)
Refactor: Rearranged code