Added threading to define-handler