added repeats and fixed error
fixed masking error