fixed title tag and tidy up code