Yet another try of working code