Added almost working code