add init state
first version
move logic to controller function
add testing