refactored code to better match assignment instructions; still functions as before