Key is now generated only once to avoid wasting resources