final code w/o comments