improve credential validation