generalized
minor edits
added assertions