Added error handling for form actions