refactored javascript to use knockout