Implemented mrnoe's suggestions