added initial exception handling to check for zero length and excessive length inputs