added some new functions, cleaning up