Code updated from original repository