Finish database quieries