better handling more edge cases