Added some error Detection.