generalizing code