Reviewed, refactored, backup function added