refactored some database queries and the way "adopted" is stored