init commit, solved first problem, explanation in answer.js comments