some code refactorying.