fix bug when wrong usage may crash app.