refactor controller code
merge