Added error checking for invalid number formats
Updated version