some code refatory.