Implements main method