Adressed performance concern and fixed a copy paste bug