Added all functionality: Not fully tested