Changed half of code. Now it is faster, better and well-coded!