modularisation of read/write to the database part 1