take the logic code into a class