Speed improvements but a fail in logic of take periodic