passes tests for machine problem 3