implemented all functionality