Added error functionality