Modified to check if the account is locked

Added logic to check if the user is locked