Made a little more efficient, still very inefficient