Added generic method to retrieve data from database