Fixed minor bug TODO: recode