fixed: incorrect result in function