I would put this inside the function with a ``defined`` check in the condition as well instead of making the function definition conditional and duplicating most of it