added code to dynamically preserve title