Refactor into more clear Model/Controller