Improved version, with alignment