refactored code to check OBJECTS and DETAILS table