all cases working, need to improve speed a bit