Updated to (hopefully) working version