made runnable in browser
removed setting value to -1 upon invalid values (behaviour too unexpected)