genericize types a bit