added swapping for stack frames