rearrange code to crust and core