mostly works, need to change the remaining character rule and do documentation