Made code more efficient