Added check for new / existing database
Moved code for adding invalid entries to own function