cleanup, call function instead of replicated code