Reorganized code to read more logically.
Fixed config and parsing to address logic of assignment missing