fix code logic