Added headers into request and replaced some lines of code with a list comprehension