bugs fixed at infinite looping