added error detection and visualization to write permission logic