prime: improved code slightly