Better version of main.js