refactored regex check and added null password check