Restructuring to avoid memory storage