refactored js into business logic and presentation ui files