refactored the code
move block logic to its own file and clean up app.js