update switchable add function to fix insertfore last index bug.
Fixes #317.