Making code more efficient