modified comparsion function