Added some important tweaks to make it work