Edit function added
added error messages