Updated functions with auto-label-detection