First version.. Has some bugs. Solving.