refactored a little
refactored the javscript files