finished code, screenshot added