implemented mocj javascript logic