further improvements for final version