refactored javascript and template files into components