added error commenting and fixed string length comparison parameter