Fixed a bug with the last implementation.