refactored some code to fetch only the attributes that are required