fixed undefined index errors