Replace get_or_create with try...except