some code simplification, some removing code duplication, some elixirization