added error message and threading system