the then has an endif so its not the problem