removed infinite loop so program terminates after 1 calculation