updated and works better now