edited based on spencer's edits