adding some rules to melody algorithm