gateway and verify functions