refactor and add backup support
refactor