tests passed for all scenarios, needs refactor