Modified to handle fractinal numbers