simplified code
added coverity status