writing code for the knowledge engine