genericifying more code