some code improvement/cleanup