refactor to use a controller
functional programming, or something?