break out controller code

Signed-off-by: Adam Stokes <adam.stokes@ubuntu.com>