add gettitle method and refactor a little