move extractKey method to the service