Use loops instead of repeating code