Added Loop and Adaptation Code, Not Tested