remove dirty code and fix bug