Database duplicate return fix

This fix the return value when the ID generated is already in DB.

Test using 1 lenght and "123456789" alphabet, now dont work, return is null.

Also remove empty spaces.