same as previous version, bugs fixed