Fixed a bug with leave