updated text
added test case and fixed logcic error