Some Edge cases corrected.