fix to actually work (modifications adapted from slime)