Refactored code and moved it into a plugin structure