refactor. work on exceptions