Moved code into classes