put public functions into object, kept controller private

controller also not global var now