Refactor adding entries (separate function for this)