Fix potential performance bug