solved problem 10, factored out functions into common.js