refactor code by removing dead veriables