Adding a cycle for basic filtering and insertion into the database