Implemented variable logic and for loop sentence