rearranged the if-then;still adds a column every time