main.js tidying up