Bug fixed. Index out of bound