put some of the code in proper place