removing logic from html and adding it to the controller