refactored order of calls