Re-factory code