refactor; work on fail case