Adding javascript logic