moved title function inside