Finish logic code