rearrange methods
extract more helpers
Use exceptions for exceptional conditions