Added some methods for querying database.