Bug fix. Added random replacement