Better handling of the edge cases