Improved Swing Function