Adding program history functionality on  the user side, refactor code