Moved to numpy for streamlined computation