Made code slightly more efficient