Refactored code. Added selects in ed attainment.