Cleaned code, changed calling style, made it work