added query method in database