added try except block to race condition