updated and tested. should work.