added patch from Samuel Kvasnica