Small bug fix with undefined variable