vectorize code cleanup