speeding up prep_value