code tidying
tidying & null ref aversion for flash message on deleting a chapter