Thanks to Oddx. I just tested his changes, fixed some issues and then refactored code.
Thanks to Oddx & geoGolem