clean logic code