Allocatable version
corrected small error
Random