added new functions and prolog pattern