Fixed error in new function