consolidated logic for retrieving data