moved fuzzy logic code