fix bug in binary functions