finish memory hierarchy code