Could we move this function outside this method in order not to create this object several times?