refactored out duplicated code
Merge remote-tracking branch 'origin/master'