check for row existence to prevent infinite loop