restructure and add functionality