fixed index error and added more debugging statements