working code with require