added loop and other things i dont remember