refactored flush and read
Merge pull request #19 from pkit/auth

refactored flush and read