Upgraded version with bugfix