rewrite for study reasons, made it faster?