refactory source code