improving code efficiency