Reverted to working code