some code refactors