Added python script and some checks to loop