Complete with Documentation and test-cases by Pranjal