base code with 2 read functions