final code is hereeeeee