COMPLETE WORKING VERSION