fixing bug + performance