Refactored some and added read a case (untested)