updated for integer ids and optional credentials