refactored code and added enc-base64.js, and removed unwanted stuff