deleted some lines in first code block for better clarity