refactored some old code in compiler and reshaped index