improvements!!! working version