added functionalities and solved bugs