Added some checks;
Needs debugging;