changed SF.loop to accept input