modified ninja solution