reorganized variable code