Refactored code. Fixed so that a new task is rendered instantly in the ui after adding it to db (no refresh etc)