implemented authentication check for read and write