small change to make class more readable

I moved definiton of variables before if satement. like suggeted.