Fixed minor bug with functions