Updating data manipulation funtions with more sanity checking