Updated with simply working code.