Rearranged code, using winston as logger