Working implementation

Commit first working implementation of the code.