Update main.js

Added the Clear block and changed the code in order to close #2.