added a new function called addElementToRight