Added error handling for 0 and negative numbers