adrians code now reasonably working