added reload button, refactored js code