Cleaned up class_data function