Updated thread to avoid undefined errors