updated with credential file

also removed unwanted portions and added some error checking condition too.