commented basic logic code