Moved a library logic from sample module to library module