Should fix #23, implemented solution with reordering of rules