Fixing indentation and adding comments
Create populateDominated function to move some logic out to a helper