Undefined index bug corrected