split some logic into separate files

add controller