Added error validation