The logic here seems wrong. It looks like you're only operating on the first element of `master_list` because of the `break` at line 217.