cleaner code and commented the functions