restructured defaultController into a function