Second phase : adding function frames