Updated with partially working code