Added code needed to fix blocking problem but problem not quite solved