Modified to be more generic.