added more functions and explanation