an attempt to refactor for readability