refactor interceptor functionality to a factory