Updated with seemingly working code
feel free to check it out, refer to comments at bottom and on facebook
page for more details