ticket:3 Added input data check and some comments