Edited functions for database