Refactored todo js