move detector to a static lib file