fixing bug to increase performance