Fixed patch based on testing from Andreas