use function variables to avoid code repetition