remove duplication by extracting 'let'