updated,still needs fixing with read/write blocking