more tweaks but getting error message about undefined offset