complete version, feedback pending