added functionality, needs some testing