added functionalities, better organisation