Fixes bug in fix for #17, removes double applicaton of function