Added some API things
Added optimization.
Perfect match