code which was tested for polewalk and swing