remove unused variable and fix a bug