Refactor angular controllers to use  instead of setTimeout