major changes, add functions