more refactor and code clean up 2