working code for second_app