[IMP] Improved code as suggested