Tidied up behaviour. Added if modified function.