updates to make sure duplicate entries are not added to the database (and hence throwing an operational error)

Signed-off-by: arghdos <arghdos@users.noreply.github.com>
minor fixes

Signed-off-by: arghdos <arghdos@users.noreply.github.com>