refactored scalar transformation