Add function to check if appid exists