finished final code