Added threading for the query so not to block the interface while executing said query.