clean up old code + wrapped function