- Added some safeguards for edge cases