fix bug, remove unused code