fix bug infite loop