Added error checks in the flash scope