Fixed bug with unpure functions