all columns added, but logical problem in function