Added error management code