added bottom to top algo and clicking