functions instead of class; other minor edits