added judge function