Cleaned up example logic code