cleaned up app.js into separate functions, fixed timeLimit problem.