imporoved sturcture for the codes 1-4