Refactored persona js code