fix "Notice: Undefined variable: extension", "Notice: Undefined index: remove"