JCR-2249 : Re-factory code