should solve race conditions