code modificated and commented, screenshot added