logic code for medlainer project