few code refactoring/cleanup

removed unnecessary casts
replace String.indexOf with String.contains