optimize code for performance