Moved most api logic to back-end