initial implementation from nodefloyd
fixed missing params