improved error msg and removed duplicate string