rewrote version of mesea by OpenSides