improved code & added secondary unit tests that use dummy input