improving data gathering logic