Improved code a bit