Updated for consistent variable handling