(refactor) cleaned up some code for readability