using delayed input but merged with older function