Refactored Gun.js to fix the bug