More modular structure for js function. The page refreshes when settings are saved or resetted