updated logic of parsing js