some code cleaning & refining