added more error functionality