local variables,dom structure, trim() issues resolved