added a lot of debug statements
found the problem and fixed it
added writerThread
found the problem and fixed it
added writerThread