add while and factor