fixed undefined index bug