Refactor the user part and main.js