Added 'midpoint' function