added pichout/pinchin and swap code