Added error check