worked to minify same functionality as before, with less code and no reflection