Refactory

@m1ch1 Just let you know how the code looks like after code refactory. You can take a look if this is what you want.