finish top level functions