work in progress (working at line 518)