Start porting code to reader monad