added the code which deletes the nodes which are smaller than the next nodes value