scan working ang querying the database