Add helper functions.

repair incorect indexes...