some code generalizations