@Override
    public String parseCommand(StateContext stateContext, String command) {
        // delims are the fields delimeters used in parsing commands
        final String delims = "[ ]+";
        String response = "";
        String[] tokens = null;

        // Ignore commands that contain nothing
        if (!command.isEmpty()) {
            tokens = command.split(delims);
        }

        if (tokens.length > 0) {
            if (validCommands.contains(tokens[0].toLowerCase())) {
                String s = tokens[0].toLowerCase();
                if (s.equals("user")) {
                    setUsername(tokens);
                    if (this.userName.isEmpty()) {
                        response = ERR + "Username was not sent" + CRLF;
                    } else {
                        response = OK + this.userName + CRLF;
                    }
                } else if (s.equals("pass")) {
                    setPassword(tokens);
                    if (!this.password.isEmpty()) {
                        setValidUser();
                        if (this.validUser) {
                            response = OK + "Welcome " + this.userName + CRLF;
                        } else {
                            attempts++;
                            response = ERR + "Invalid username/password combination " + Integer.toString(maxAttempts - attempts) + " attempts left" + CRLF;
                        }
                    } else {
                        response = ERR + "Must send password" + CRLF;
                    }
                } else if (s.equals("quit")) {
                    response = OK + "Server closing connection" + CRLF;
                    closeConnection(stateContext);
                }
            } else {
                response = ERR + "Unknown command" + CRLF;
            }
        }
        return response;
    }