new version
working code