Added a large part of implementation