update based on tomprince's edits