restructured code

reorganized methods & declarations