Refactored to organize code under a Snippet class.
Refactored Snippet class to be independent of query
removed and refactored some duplicated code