Added error checking for stat