improving code complexity