Might have fixed the infinite loop problem...