rough implementation in ruby