fixed issues in scalar implementation