Improving code sructure