fix bugs in scalar arithmetic