massive changes for optimization