some fixes and implementation