made code more efficient

Made code more efficient.