error handling working, needs testing and ooping