Added another function; updated SQL