improving buttons loop efficiency