Fixed a bug that made the function called before the controller constructor