added scaling and shifting