encode stuff in db correctly