writing function to print middle