minor changes, working ver