lots of changes and new functions