still works before refactor - lots of extraneous code