Code rewritten

Code rewritten to support public methods