Added input correctness check