finished everything except logging and error handling