some changes to remove notice undefined variable