Add functional code and final model