refactor to controllers
fixed miscalculations