Got rid of infinite loop