Version 1.05: optimized code a bit