Made code a little more efficient