fix little bug in getting the text from view
some cleaning up of code