restructure functions