updated controller code (still missing crypto)