Fixed addScalar function logic.