Added edge cases check