fix bug in which function