I rewrote it. you can have a look. raising an exception for every items might be costly...T