correct logical error in new function