Completed working version