fixes an xpath issue
adds minor code refactor