This bit of code appears above as well. Consider making a helper function out of it. DRY!