Added error checking for some commands