added match, added more guards to api funcs