Handling exception in PC read/write. Working copy of code