added scaling and flip