Added function to handle orientation change